<?php
use yii\helpers\Url;
use yii\web\View;
$this->title = $this->context->pageTitle.Yii::$app->params['titleSuffix'];
$jsMsgs = $this->context->loadJsMsgs([
  'login'
]);
$this->registerJs("VAM.setVar('LANGUAGE_JS', '".$jsMsgs."');", View::POS_HEAD);
?>
<div class="row">
  <div class="login-holder">
    <div class="logo-container">
      <!-- Logo -->
      <h1 class="">
        <img src="<?= Yii::getAlias('@web/').Yii::$app->params['envDir'];?>/img/new-logo.png" title="ValueMaker Ad Server" alt="ValueMaker Ad Server">
      </h1>
      <!-- /Logo -->
    </div>
    <div class="form-container">
      <div id="login-loading-wrap" class="local-loading-wrap" style="display: block;">
        <div class="loading-section-wrap text-center" style="top: 20%;">
          <div class="spinner">
            <div class="bounce1"></div>
            <div class="bounce2"></div>
            <div class="bounce3"></div>
          </div>
          <p class="login-loading-tips" style="display:none;"><?=\Yii::t('site', 'Loging')?>...</p>
          <p class="init-loading-tips"><?=\Yii::t('common', 'loading')?>...</p>
        </div>
      </div>
      <div class="login-container">
        <!-- Title -->
        <h3><?=\Yii::$app->params['sysMsg']['company']?> 代理投放 <small><?=\Yii::t('site', 'Login')?></small></h3>
        <hr>
        <p><?=\Yii::t('site', 'Please input username and password.')?></p>
        <!-- /Title -->
        <!-- Login Form -->
        <form class="form-horizontal" id="data-form" method="post" action="<?= Url::to(['site/login'])?>" role="form">
          <input id="login-role" type="hidden" name="role" value="">
          <input id="login-checky" type="hidden" name="checky" value="">
          <div class="form-group">
            <div class="input-group input-group-lg">
              <span class="input-group-addon" id="username-addon"> 
                <i class="fa fa-user"></i>
              </span>
             <input type="text" class="form-control" placeholder="<?=\Yii::t('site', 'email')?>" name="user_email" aria-describedby="useremail-addon" id="user_name">
            </div>
            <div class="help-block text-error" id="user-name-err"></div>
          </div>
          <div class="form-group">
            <div class="input-group input-group-lg">
              <span class="input-group-addon" id="username-addon"> 
                <i class="fa fa-lock"></i>
              </span>
              <input type="password" class="form-control" placeholder="<?=\Yii::t('site', 'password')?>" name="user_pwd" aria-describedby="username-addon" id="user_pwd">
            </div>
            <div class="help-block text-error" id="user-pwd-err"></div>
          </div>
          <div class="form-group field-login-verifycode">
            <div class="input-group input-group-lg">
              <span class="input-group-addon" id="verifycode-addon">
                <i class="fa fa-code"></i>
                </span>
              <input type="text" id="verifycode" class="form-control" name="verifycode" placeholder="<?=\Yii::t('site', 'captcha')?>">
              <div class="input-group-addon verifycode-image-wrap">
                <img id="verifycode-image" class="verifycod-image" src="<?= Url::to(['site/captcha']);?>" alt="<?=\Yii::t('site', 'fresh captcha')?>" title="<?=\Yii::t('site', 'fresh captcha')?>">
              </div>
            </div>
            <div class="help-block text-error" id="verifycode-err"></div>
          </div>
          <div class="form-group">
            <div class="text-center">
              <button class="btn btn-primary btn-block btn-wide" type="submit" title="<?=\Yii::t('site', 'Login')?>" disabled>
                <?=\Yii::t('site', 'Login')?>
                <i class="fa fa-play-circle"></i>
              </button>
            </div>
          </div>
          <div class="form-group form-group-sm">
            <div class="col-sm-7 col-xs-8 col-sm-push-5 col-xs-push-4 pr0">
              <label for="sys-lang-switch" class="col-sm-7 control-label pr10"><?=\Yii::t('site', 'Language')?>: </label>
              <div class="col-sm-5 plr0">
                <select class="form-control" id="sys-lang-switch">
                  <option value="zh-CN" <?php if($language == 'zh-CN') echo "selected";?>>中文</option>
                  <option value="en-US" <?php if($language == 'en-US') echo "selected";?>>English</option>
                </select>
              </div>
            </div>
          </div>
          <p><?=\Yii::t('site', 'Please use modern browser, like Chrome, Firefox or IE9+')?></p>
          <hr>
          <div class="extra-operate">
            <ul class="list-inline">
              <li>
                <i class="fa fa-desktop" title="PC"></i>
                &nbsp;
                <i class="fa fa-tablet" title="<?=\Yii::t('site', 'Pad')?>"></i>
                &nbsp;
                <i class="fa fa-mobile" title="<?=\Yii::t('site', 'Mobile')?>"></i>
              </li>
            </ul>
          </div>
        </form>
      </div>
    </div>
  </div>
</div>
<?php
  $nextUrl = Url::to(['home/dashboard']);
  $swichLanguageUrl = Url::to(['site/set-login-language']);
  $this->registerJs("VAM.setVar('NEXT_URL','$nextUrl');", View::POS_HEAD);
  $this->registerJs("VAM.setVar('SWITCH_LANGUAGE_URL','$swichLanguageUrl');", View::POS_HEAD);
  // $this->registerJsFile("@web/".Yii::$app->params['envDir']."/js/site/login.js", ['position' => View::POS_HEAD, 'depends' => 'app\assets\IndexAsset']);
?>
<script type="text/javascript" >
  require(["<?= Yii::getAlias('@web/').Yii::$app->params['envDir'];?>/js/site.js"], function(common) {
    require(["<?= Yii::getAlias('@web/').Yii::$app->params['envDir'];?>/js/site/login.js"]);
  });
</script>
